<!--
 * @Author: wangshiyang
 * @Date: 2023-06-19 13:39:59
 * @LastEditors: wangshiyang
 * @LastEditTime: 2023-06-19 14:42:35
 * @Description: 请填写简介
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="referrer" content="no-referrer" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='https://api.mapbox.com/mapbox-gl-js/v2.12.0/mapbox-gl.js'></script>
    <link href='https://api.mapbox.com/mapbox-gl-js/v2.12.0/mapbox-gl.css' rel='stylesheet' />
    <script src='https://unpkg.com/@antv/l7'></script>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        #map {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
        }

        #marker {
            text-align: center;
            background-color: #c882eb92;
            line-height: 50px;
            color: #fff;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div id="map">

    </div>
    <script>
        const { PointLayer, Popup, Marker, MarkerLayer } = L7;
        const token = 'pk.eyJ1IjoiY2hlbmdiZW5jaGFvIiwiYSI6ImNsODU3aGRiODA0Y2UzcHBzZmFlcmdqZ2sifQ.8k59W_pB_Riwe6o-MneRlA'
        mapboxgl.accessToken = token;
        const map = new mapboxgl.Map({
            container: 'map', // container id
            style: 'mapbox://styles/mapbox/streets-v11', // stylesheet location
            center: [114.30, 30.50], // starting position [lng, lat]
            zoom: 14, // starting zoom
            pitch: 70
        });

        const scene = new L7.Scene({
            id: 'map',
            map: new L7.Mapbox({
                mapInstance: map,
            }),
        });
        const data = [{
            lng: 114.30,
            lat: 30.50,
            name: "白沙洲"
        }, {
            lng: 114.40,
            lat: 30.45,
            name: "中南路"
        }
        ]
        scene.on('loaded', () => {
            // 添加图片标注
            // scene.addImage("police", "./警察.png")
            // const policeLayer = new PointLayer();
            // policeLayer.source(data, {
            //     parser: {
            //         type: 'json',
            //         x: 'lng',
            //         y: 'lat'
            //     }
            // })
            //     .shape('police')
            //     .size(16)
            // scene.addLayer(policeLayer)

            const data = {
                type: "FeatureCollection",
                features: [
                    {
                        type: "Feature",
                        geometry: {
                            type: "Point",
                            coordinates: [
                                114.30,
                                30.50
                            ]
                        },
                        properties: {
                            name: "武汉市",
                            height: 400
                        }
                    }
                ]
            }

            // 添加散点标注
            const pointLayer = new PointLayer({})
                .source(data)
            pointLayer.animate(true)
                .color('#652e80')
                //shape设置为circle
                .shape('circle')
                .size('height', h => {
                    return h
                })
                .active(true)
            scene.addLayer(pointLayer);

            // 添加雷达标注


            // const pointLayer = new PointLayer({})
            //     .source(data)
            // pointLayer
            //     .shape('radar')
            //     .size(200)
            //     .color('#f00')
            //     .animate(true);
            // scene.addLayer(pointLayer);
        });

    </script>
</body>

</html>